#!/bin/sh
cd `dirname $0`
#容器名称每个人修改为自己的
contrainsname="qrcode"
contrainshave=`docker ps -a --filter name=$contrainsname --filter status=running`
if [[ $contrainshave == *$contrainsname* ]]
then
    echo "$contrainsname 容器正在运行"
	docker stop $contrainsname
fi
contrainshave=`docker ps -a --filter name=$contrainsname`
if [[ $contrainshave == *$contrainsname* ]]
then
	echo "$contrainsname 容器已经存在，先进行删除"
	docker rm $contrainsname
fi
echo "$contrainsname 容器不存在，开始创建"
#修改dll的目录名称、dll的名称
dlldir="/home/xjj/qrcode"
#修改-p对应的参数为自己的端口号
docker run --ulimit core=0 --ulimit nofile=65536:65536 --ulimit nproc=65536:65536 --privileged=true -v $dlldir:$dlldir -v /home/ldt/ldt.judgetdoc.worktemplate:/home/ldt/ldt.judgetdoc.worktemplate --name $contrainsname -p 18003:18003 -it -v /etc/localtime:/etc/localtime:ro mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic bash

sleep 1
contrainshave=`docker ps -a --filter name=$contrainsname --filter status=running`
if [[ $contrainshave == *$contrainsname* ]]
then
	echo "$contrainsname 容器启动成功，开始运行"
else
	echo "$contrainsname 容器启动失败"
	exit 1		
fi		

wget https://github.com/opencv/opencv/archive/4.7.0.zip && \
    unzip 4.7.0.zip && \
    rm 4.7.0.zip && \
    mv opencv-4.7.0 opencv && \
    wget https://github.com/opencv/opencv_contrib/archive/4.7.0.zip && \
    unzip 4.7.0.zip && \
    rm 4.7.0.zip && \
    mv opencv_contrib-4.7.0 opencv_contrib
	
	
docker run --ulimit core=0 --ulimit nofile=65536:65536 --ulimit nproc=65536:65536 --privileged=true -v /home/xjj/qrcode:/home/xjj/qrcode -v /home/ldt/ldt.judgetdoc.worktemplate:/home/ldt/ldt.judgetdoc.worktemplate --name qrcoderelease -p 18006:18003 -it -v /etc/localtime:/etc/localtime:ro mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic bash	

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/xjj/qrcode/runtimes/arm


cmake \
    -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D BUILD_SHARED_LIBS=OFF \
    -D ENABLE_CXX11=OFF \
    -D BUILD_EXAMPLES=OFF \
    -D BUILD_DOCS=OFF \
    -D BUILD_PERF_TESTS=OFF \
    -D BUILD_TESTS=OFF \
    -D BUILD_JAVA=OFF \
    -D BUILD_opencv_app=OFF \
    -D BUILD_opencv_java_bindings_generator=OFF \
    -D BUILD_opencv_python_bindings_generator=OFF \
    -D BUILD_opencv_python_tests=OFF \
    -D BUILD_opencv_ts=OFF \
    -D BUILD_opencv_js=OFF \
    -D BUILD_opencv_bioinspired=OFF \
    -D BUILD_opencv_ccalib=OFF \
    -D BUILD_opencv_datasets=OFF \
    -D BUILD_opencv_dnn_objdetect=OFF \
    -D BUILD_opencv_dpm=OFF \
    -D BUILD_opencv_fuzzy=OFF \
    -D BUILD_opencv_gapi=OFF \
    -D BUILD_opencv_intensity_transform=OFF \
    -D BUILD_opencv_mcc=OFF \
    -D BUILD_opencv_rapid=OFF \
    -D BUILD_opencv_reg=OFF \
    -D BUILD_opencv_stereo=OFF \
    -D BUILD_opencv_structured_light=OFF \
    -D BUILD_opencv_surface_matching=OFF \
    -D BUILD_opencv_videostab=OFF \
    -D WITH_GSTREAMER=OFF \
    -D OPENCV_ENABLE_NONFREE=OFF \
	-D WITH_CUDA=OFF \
	-D BUILD_TIFF=OFF \
	-D WITH_V4L=OFF \
	-D VIDEOIO_ENABLE_PLUGINS=OFF \
	-D WITH_IPP=OFF \
    ..
	
cmake -DBUILD_LIST=WITH_PNG WITH_JPEG ..	


cmake \
    -D OPENCV_EXTRA_MODULES_PATH=/home/xjj/qrcode/runtimes/arm/opencv_contrib/modules \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D BUILD_SHARED_LIBS=OFF \
    -D ENABLE_CXX11=ON \
    -D BUILD_EXAMPLES=OFF \
    -D BUILD_DOCS=OFF \
    -D BUILD_PERF_TESTS=OFF \
    -D BUILD_TESTS=OFF \
    -D BUILD_JAVA=OFF \
    -D BUILD_opencv_app=OFF \
    -D BUILD_opencv_java_bindings_generator=OFF \
    -D BUILD_opencv_python_bindings_generator=OFF \
    -D BUILD_opencv_python_tests=OFF \
    -D BUILD_opencv_ts=OFF \
    -D BUILD_opencv_js=OFF \
    -D BUILD_opencv_bioinspired=OFF \
    -D BUILD_opencv_ccalib=OFF \
    -D BUILD_opencv_datasets=OFF \
    -D BUILD_opencv_dnn_objdetect=OFF \
    -D BUILD_opencv_dpm=OFF \
    -D BUILD_opencv_fuzzy=OFF \
    -D BUILD_opencv_gapi=OFF \
    -D BUILD_opencv_intensity_transform=OFF \
    -D BUILD_opencv_mcc=OFF \
    -D BUILD_opencv_rapid=OFF \
    -D BUILD_opencv_reg=OFF \
    -D BUILD_opencv_stereo=OFF \
    -D BUILD_opencv_structured_light=OFF \
    -D BUILD_opencv_surface_matching=OFF \
    -D BUILD_opencv_videostab=OFF \
    -D WITH_GSTREAMER=OFF \
    -D OPENCV_ENABLE_NONFREE=ON \
    ..
	
	
	
	cmake -D CMAKE_INSTALL_PREFIX=/home/xjj/qrcode/runtimes/arm/opencvsharp/make /home/xjj/qrcode/runtimes/arm/opencvsharp/src
	
	cp /home/xjj/qrcode/runtimes/arm/opencvsharp/make/lib/libOpenCvSharpExtern.so /usr/lib
	
	docker save -o my_ubuntu_v3.tar aspnet:3.1-opencv
	
	
	cp /lib/aarch64-linux-gnu/libusb-1.0.so.0 /home/xjj/qrcode/runtimes/arm/
	cp /home/xjj/qrcode/runtimes/arm/libusb-1.0.so.0 /usr/lib/aarch64-linux-gnu
	
	
	
	export LIBRARY_PATH=/home/xjj/qrcode/runtimes/arm:$LIBRARY_PATH 


